﻿<UserControl
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:sys="clr-namespace:System;assembly=mscorlib"
   xmlns:types="clr-namespace:SQLToolbox.Types;assembly=SQLToolbox.Types"
   xmlns:local="clr-namespace:SQLToolbox.View.UserControls"
              x:Class="SQLToolbox.View.UserControls.SchemaComparisonResultsViewer"
              MinHeight="300" MinWidth="300">
    <UserControl.Resources>
        <!--<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="actionDataProvider">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="types:ComparisonAction"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>-->
        <local:UpdateActionVisibilityConverter x:Key="converter"/>
        <local:UpdateActionIconPathConverter x:Key="actionToIconPathConverter"/>
        <local:ComparisonStatusIconPathConverter x:Key="statusToIconPathConverter"/>
        <local:UpdateActionIconTooltipConverter x:Key="actionToTooltipConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60*"/>
            <ColumnDefinition Width="40*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>
        <ListView Name="lv1" Grid.Column="0" Grid.Row="1" 
                      VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                      BorderBrush="#888" BorderThickness="3,3,3,3"  Background="#FFD4D0C8" Margin="2,2,2,2">
            <ListView.Resources>
                <Style TargetType="ListViewItem">
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFB6BDD2"/>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FFA6AFC9"/>
                    </Style.Resources>
                </Style>
                <!--<SolidColorBrush x:Key="OverBackground" Color="#FFF5F5F5"/>-->
                <SolidColorBrush x:Key="PressedBackground" Color="#FFA6AFC9"/>
                <SolidColorBrush x:Key="NormalBorder" Color="#FF969696"/>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="BorderBrush" Value="{StaticResource NormalBorder}"/>
                    <Setter Property="BorderThickness" Value="1"/>
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="Padding" Value="3,3,3,3"/>
                    <!--<Setter Property="MinHeight" Value="30"/>
                   <Setter Property="MinWidth" Value="50"/>-->
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Grid>
                                    <Border SnapsToDevicePixels="true" x:Name="Chrome" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0" Opacity="0" />
                                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                                </Grid>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Opacity" TargetName="Chrome" Value="1"/>
                                        <!--<Setter Property="Background" TargetName="Chrome" Value="{DynamicResource OverBackground}" />-->
                                    </Trigger>
                                    <Trigger Property="IsPressed" Value="True">
                                        <Setter Property="Opacity" TargetName="Chrome" Value="1"/>
                                        <Setter Property="Background" TargetName="Chrome" Value="{DynamicResource PressedBackground}" />
                                    </Trigger>
                                    <Trigger Property="IsEnabled" Value="false">
                                        <Setter Property="Foreground" Value="#ADADAD"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListView.Resources>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Margin" Value="0,0,0,5"/>
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander IsExpanded="True">
                                            <Expander.Header>
                                                <DockPanel>
                                                    <TextBlock FontWeight="Bold" DockPanel.Dock="Left" Text="{Binding Name}" Margin="5,0,0,0" Width="200"/>
                                                </DockPanel>
                                            </Expander.Header>
                                            <Expander.Content>
                                                <ItemsPresenter />
                                            </Expander.Content>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListView.GroupStyle>

            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Action">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button Visibility="{Binding Path=LeftToRightAction, Converter={StaticResource converter}}"
                                       Click="GridItemLeftButton_Clicked">
                                    <Image Height="16" Width="16">
                                        <Image.Source>
                                            <Binding Path="LeftToRightAction"
                                               Converter="{StaticResource actionToIconPathConverter}">
                                                <Binding.ConverterParameter>
                                                    <types:UpdateDirection>LeftToRight</types:UpdateDirection>
                                                </Binding.ConverterParameter>
                                            </Binding>
                                        </Image.Source>
                                        <Image.ToolTip>
                                            <Binding Path="LeftToRightAction"
                                               Converter="{StaticResource actionToTooltipConverter}">
                                                <Binding.ConverterParameter>
                                                    <types:UpdateDirection>LeftToRight</types:UpdateDirection>
                                                </Binding.ConverterParameter>
                                            </Binding>
                                        </Image.ToolTip>
                                    </Image>
                                </Button>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Type" Width="50" >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=LeftText}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <Image Height="16" Width="16" Source="../Resources/LeftDB.ico"/>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Status">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image Height="16" Width="16" Source="{Binding Path=Status, 
                                    Converter={StaticResource statusToIconPathConverter}}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=RightText}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <Image Height="16" Width="16" Source="../Resources/RightDB.ico"/>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Action">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button Visibility="{Binding Path=RightToLeftAction, Converter={StaticResource converter}}"
                                        Click="GridItemRightButton_Clicked">
                                    <Image Height="16" Width="16">
                                        <Image.Source>
                                            <Binding Path="RightToLeftAction"
                                               Converter="{StaticResource actionToIconPathConverter}">
                                                <Binding.ConverterParameter>
                                                    <types:UpdateDirection>RightToLeft</types:UpdateDirection>
                                                </Binding.ConverterParameter>
                                            </Binding>
                                        </Image.Source>
                                        <Image.ToolTip>
                                            <Binding Path="RightToLeftAction"
                                               Converter="{StaticResource actionToTooltipConverter}">
                                                <Binding.ConverterParameter>
                                                    <types:UpdateDirection>RightToLeft</types:UpdateDirection>
                                                </Binding.ConverterParameter>
                                            </Binding>
                                        </Image.ToolTip>
                                    </Image>
                                </Button>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
            <!--<types:SchemaObjectComparison LeftText="Left" Name="test" RightText="Right" Status="Different" Type="Table"/>-->
        </ListView>
        <GridSplitter Name="gridSplitter1" Grid.RowSpan="2" Width="3" Background="Transparent"/>
        <!--<GridSplitter Name="gridSplitter1" Grid.RowSpan="2" Grid.Column="0"/>-->
        <DockPanel Grid.Row="1"  Grid.Column="1">
            <local:TextComparer x:Name="comparer" BorderBrush="#888" BorderThickness="3,3,3,3"  Background="#FFD4D0C8" Margin="2,2,2,2"/>
        </DockPanel>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition ToolTip="Left database" Width="50*"/>
                <ColumnDefinition Width="16"/>
                <ColumnDefinition ToolTip="Right database" Width="50*"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="LDatabase" FontSize="14" FontWeight="Bold" HorizontalAlignment="Right" Grid.Column="0" Margin="0,0,5,0" Text=""/>
    		<Image Source="../Resources/Swap.ico" Width="16" Height="16" Grid.Column="1" />
    		<TextBlock x:Name="RDatabase" FontSize="14" FontWeight="Bold"  HorizontalAlignment="Left" Grid.Column="2" Margin="5,0,0,0" Text=""/>
    	</Grid>
        
        <StatusBar Grid.Row="2" Grid.ColumnSpan="2" Height="25" HorizontalAlignment="Stretch" Background="Transparent">
            <StatusBarItem HorizontalAlignment="Left">
                <TextBlock Name="status" />
            </StatusBarItem>
        </StatusBar>

    </Grid>
</UserControl>

